﻿Imports System.Data.OleDb

Public Class CargoService
    Public Function findAll() As List(Of Cargo)
        Dim lista As New List(Of Cargo)

        Dim con = contexto.conBD
        Try
            Dim cmd As New OleDbCommand()
            cmd.Connection = con
            con.Open()

            Dim sql As String = "select * from Cargo"
            cmd.CommandText = sql
            Dim dr As OleDbDataReader = cmd.ExecuteReader()
            While dr.Read
                Dim e As New Cargo
                e.codigo = dr("P_CARGO").ToString()
                e.nombre = dr("P_DESCARGO").ToString()
                lista.Add(e)
            End While

        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            con.Close()
        End Try

        Return lista
    End Function
End Class
